﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Alos.Entity;
using Alos.IRepository;
using PetaPoco;

namespace Alos.Repository
{
    public class ReObjectiveQuestionRepository : BaseRepository<ReObjectiveQuestion>, IReObjectiveQuestionRepository
    {
        /// <summary>
        /// 学生提交记录(客观题)
        /// </summary>
        /// <param name="ReObjectiveQuestions"></param>
        /// <returns></returns>
        public bool CreateKeGuan(List<ReObjectiveQuestion> ReObjectiveQuestions)
        {
            bool tianjia = true;
            foreach (ReObjectiveQuestion item in ReObjectiveQuestions)
            {
                if (Convert.ToInt32(item.Insert()) == 0)
                {
                    tianjia = false;
                }
            }
            return tianjia;
        }
        /// <summary>
        /// 统计学生提交记录（客观题）
        /// </summary>
        /// <param name="ArrangeID">课程编号</param>       
        /// <returns></returns>
        public IEnumerable<dynamic> GetReObjectiveQuestionByArrangeID(int ArrangeID)
        {
            var sql = Sql.Builder.Append(@"select * from ReObjectiveQuestion a left join ReTestStem b on a.StemID=b.ID  where ArrangeID=@0", ArrangeID);
            return DBContext.Query<dynamic>(sql);
        }
    }
}
